<?php

/* * 注意此文档为UTF-8的编码.
 * Created on 2010-10-2
 *
 * @author EXT <isrn@qq.com>
 *
 */
include ('../../includes/global.php');
include ('../global.php');
include ("../power.php");
include ("../clas/ext.php");
//include ("../clas/relation.php");
//$relation = new relation();

//Initialize array for form js
$plugurl = array();
$plugjs = array();
$fckplugin = '';

//The first letter of "get real value" 
function grv($type, $blm, $dvalue=false) {
    //print_r($type);
    if ($dvalue) {
        return $dvalue;
    } else {
        switch ($type) {
            case 'function': {
                    $a = explode('#', $blm);
                    return $a[0]($a[1]);
                    break;
                }
            case '$_GET': {
                    return $_GET[$blm];
                    break;
                }
            case '$_SESSION': {
                    return $_SESSION[$blm];
                    break;
                }
            case '$_POST': {
                    return $_POST[$blm];
                    break;
                }
            case '$_COOKIE': {
                    return $_COOKIE[$blm];
                    break;
                }
            case '$_SERVER': {
                    return $_SERVER[$blm];
                    break;
                }
            case '$_ENV': {
                    return $_ENV[$blm];
                    break;
                }
            case '$_FILES': {
                    return $_FILES[$blm];
                    break;
                }
            case '0': {
                    return $blm;
                    break;
                }
            case '1': {
                    break;
                }
            default: {
                    return $blm;
                    break;
                }
        }
    }
}

//
Tr(basename($_SERVER['PHP_SELF']), 'thisurl');
Tr('系统操作日志', 'thistitle');
$_GET['tid'] = $_REQUEST['tid'];
$_POST['tid'] = $_REQUEST['tid'];
$tmpml = 'log/';
Tr($_REQUEST['tid'], 'tid');
Tr('10', 'pagenum');
$paixu = array('zd' => 'id', 'order' => 'DESC');
Tr($paixu, 'paixu');
Tr($_REQUEST['tid'], 'rightid');
Tr('0', 'hideupdata');
Tr('0', 'hideadd');
//$_SESSION['rcg']!='A'&&$_SESSION['rcg']['zdgxkey'][$_GET['tid']]=1;
//Configuration add items
$showcf = array(
    0 => array('title' => '操作信息', 'zd' => array('username', 'optime', 'ip', 'opp', 'optid', 'opid', 'modularname',)),
    1 => array('title' => '操作日志', 'zd' => array('log'))
);

$listcf = array(//Configuration list items
    'show' => array('username', 'optime', 'ip', 'opp', 'optid', 'opid', 'modularname', 'log'),
    //virtual list'
    'xnlist' => array(
    //array('id' => 453, 'fname' => 'ddcode', 'type' => 'input', 'name' => '订单编号', 'wd' => 120, 'url' => ""),
    //array('id' => 451, 'fname' => 'cname', 'type' => 'input', 'name' => '采购人', 'wd' => 120, 'url' => ""),
    //array('id' => 450, 'fname' => 'gname', 'type' => 'input', 'name' => '供货商', 'wd' => 120, 'url' => ""),
    //array('id' => 454, 'fname' => 'dgdate', 'type' => 'input', 'name' => '订购日期', 'wd' => 120, 'url' => ""),
    //array('id' => 452, 'fname' => 'dhdate', 'type' => 'input', 'name' => '到货日期', 'wd' => 120, 'url' => ""),
    //array('id' => 456, 'fname' => 'addtime', 'type' => 'input', 'name' => '制单日期', 'wd' => 120, 'url' => "")
    ),
    //Advanced search
    //'gj'=>array('user','ct','usertype'),
    //'ss'=>'ct',//olny one
    //'pt'=>" and user like '".$_SESSION['userinfo']['user']."' ",//sql
    'editdisble' => array('username', 'optime', 'ip', 'opp', 'optid', 'opid', 'modularname', 'log')
        //'zdgx'=>array('ct'),
        //'zdgxkey'=>array('ct'),
        //'save'=>array('user','ct'),
        //'zd'=>array('user','ct')
);
switch ($_REQUEST['op']) {
    case 'list': {
            $fldata = Dgd(array(
                'db' => 'd_sevenel',
                'cd' => "tid = '" . $_GET['tid'] . "' order by px asc ",
                'tn' => "fld"
                    ));
            Tr($_GET['bdtid'], 'bdtid');
            Tr($_GET['bdid'], 'bdid');
            if (count($listcf['show']) > 0) {
                foreach ($fldata as $key => $v) {
                    if (in_array($v['fname'], $listcf['show'])) {
                        $xr[] = $v;
                    }
                }
            } else {
                foreach ($fldata as $key => $v) {
                    if ($v['xr'] == 0) {
                        $xr[] = $v;
                    }
                }
            }
            if (count($listcf['xnlist']) > 0) {
                foreach ($listcf['xnlist'] as $v) {
                    $xr[] = $v;
                }
            }
            Tr($xr, 'xr');
            if (count($listcf['gj']) > 0) {
                foreach ($fldata as $key => $v) {
                    if (in_array($v['fname'], $listcf['gj'])) {
                        $gj[] = $v;
                    }
                }
            } else {
                foreach ($fldata as $key => $v) {
                    if ($v['gj'] == 1) {
                        $gj[] = $v;
                    }
                }
            }
            if ($gj != '') {
                foreach ($gj as $key => $value) {
                    $js[] = EXT::GG($value['id']);
                }
            }
            Tr($ckbox, 'ckbox');
            Tr($js, 'js');
            $gj && Tr('1', 'gjright');
            if ($listcf['ss']) {
                Tr($listcf['ss'], 'titlesearch');
            } else {
                Tr('tt', 'titlesearch');
            }
            $tree = Dgd(array(
                'db' => 'd_sevenel',
                'cd' => "id = '" . $_GET['tid'] . "' ",
                'tn' => "tree",
                'limit' => 1
                    ));
            Tr($tree, 'tree');
            if ($tree['expand']) {
                $fstree = Dgd(array(
                    'db' => 'd_sevenel',
                    'cd' => "id in (0," . $tree['expand'] . ") ",
                    'tn' => "tree"
                        ));
            }
            $fsstr = '';
            if ($fstree) {
                foreach ($fstree as $fsvalue) {
                    $fsstr.=",{xtype:\"button\",text:\"添加" . $fsvalue['title'] . "\",iconCls:\"fsadd\",pressed:true,handler:function(){
				var record = grid.getStore().getAt(rowIndex); 
				fsadd('" . $fsvalue['id'] . "','" . $fsvalue['title'] . "',\"./show1/i.php?op=add&tid=" . $fsvalue['id'] . "&bdtid=" . $_GET['tid'] . "&bdid=\",record.data.id);		}}
				,{xtype:\"button\",text:\"浏览" . $fsvalue['title'] . "\",iconCls:\"fslist\",pressed:true,handler:function(){
				var record = grid.getStore().getAt(rowIndex); 
				fslist('" . $fsvalue['id'] . "','" . $fsvalue['title'] . "',\"./show1/l.php?op=list&tid=" . $fsvalue['id'] . "&bdtid=" . $_GET['tid'] . "&bdid=\",record.data.id);
					}}";
                }
            }
            Tr($fsstr, 'fstree');
            Jc($fsstr);
            $table = Dgd(array(
                'db' => 'd_sevenel',
                'cd' => "id = '" . $tree['table'] . "' ",
                'tn' => "datamod",
                'limit' => 1
                    ));
            Tr($table, 'table');
            Ts($tmpml . '/list.html');
            break;
        }
    case 'fy': {
            if ($_SESSION['rcg'] != 'A' && !$_SESSION['rcg']['c'][$_POST['tid']]) {
                $pt = $listcf['pt'];
            }
            $fldata = Dgd(array(
                'db' => 'd_sevenel',
                'cd' => "tid = '" . $_POST['tid'] . "'  order by px asc ",
                'tn' => "fld"
                    ));
            $zhuanyi = array();
            $btsc = array();
            $gjsc = array();
            foreach ($fldata as $key => $value) {
                if ($value['zy'] == 1) {
                    $zhuanyi[] = $value;
                }
                if ($value['bt'] == 1) {
                    $btsc[$value['fname']] = $value['type'];
                }
            }
            $condition = '';
            $_POST['user'] && $condition.="and user like '%" . $_POST['user'] . "%' ";
            $_POST['bdtid'] && $condition.="and bdtid = '" . $_POST['bdtid'] . "' ";
            $_POST['bdid'] && $condition.="and bdid = '" . $_POST['bdid'] . "' ";
            if (count($listcf['gj']) > 0) {
                foreach ($fldata as $key => $v) {
                    if (in_array($v['fname'], $listcf['gj'])) {
                        $gj[] = $v;
                    }
                }
            } else {
                foreach ($fldata as $key => $v) {
                    if ($v['gj'] == 1) {
                        $gj[] = $v;
                    }
                }
            }
            if ($gj != '') {
                $xzt = array('combo', 'recommend', 'radiogroup', 'combo1');
                foreach ($gj as $value) {
                    if (in_array($value['type'], $xzt)) {
                        $_POST[$value['fname']] != '' && $condition.="and " . $value['fname'] . " = '" . $_POST[$value['fname']] . "' ";
                    } else {
                        if ($value['type'] == 'checkboxgroup') {
                            if ($_POST[$value['fname']]) {
                                foreach ($_POST[$value['fname']] as $cv) {
                                    $cv != '' && $condition.="and " . $value['fname'] . " like '%" . $cv . "%' ";
                                }
                            }
                        } else {
                            $_POST[$value['fname']] != '' && $condition.="and " . $value['fname'] . " like '%" . $_POST[$value['fname']] . "%' ";
                        }
                    }
                }
            }
            $dbinfo = Dgd(array(
                'db' => 'd_sevenel',
                'tn' => $_POST['dbname'],
                'start' => $_POST['start'],
                'limit' => $_POST['limit'],
                'total' => true,
                //'ce'=>1,
                'cd' => " 1 and del!=1 and tid = 0 " . $condition . " " . $pt . " order by " . $paixu['zd'] . "  " . $paixu['order'] . "  "
                    ));
            //统计
            //转换
            $tempb = 0;
            foreach ($dbinfo['data'] as $key => $value) {
//							$tempb+=$value['ct'];	

                foreach ($zhuanyi as $zyv) {
                    switch ($zyv['type']) {
                        case 'fileup': {
                                //echo $dbinfo['data'][$key][$zyv['fname']];
                                $config = json_decode($zyv['cfg'], true);
                                $dvalue = array(0 => array('rar', 'zip', 'tar', '.tz'),
                                    1 => array('jpg', 'gif', 'png', 'bmp'),
                                    2 => array('mp3', 'mp4', 'avi', 'wmv', 'mid', '.rm', 'mvb', 'mov', 'wma', 'wav'),
                                    3 => array('doc', 'xls', 'txt', 'ocx', 'lsx', 'ppt', 'pdf', 'chm'),
                                    4 => array('doc', 'xls', 'txt', 'ocx', 'lsx', 'ppt', 'pdf', 'chm', 'mp3', 'mp4', 'avi', 'wmv', 'mid', '.rm', 'mvb', 'mov', 'wma', 'wav', 'jpg', 'gif', 'png', 'bmp', 'rar', 'zip', 'tar', '.tz')
                                );
                                $otype = substr(strtolower($dbinfo['data'][$key][$zyv['fname']]), -3);
                                if (in_array($otype, $dvalue[0])) {
                                    $dbinfo['data'][$key][$zyv['fname']] = "<a href=\"/uplods/pic/" . $dbinfo['data'][$key][$zyv['fname']] . "\" target='_blank'><img src=\"../img/archive.png\">下载[Download]</a>";
                                }
                                if (in_array($otype, $dvalue[1])) {
                                    if ($config['sl1'] == 1) {
                                        $dbinfo['data'][$key][$zyv['fname']] = "<img src=\"/uplods/thumb1/" . $dbinfo['data'][$key][$zyv['fname']] . "\" >";
                                    } elseif ($config['sl2'] == 1) {
                                        $dbinfo['data'][$key][$zyv['fname']] = "<img src=\"/uplods/thumb2/" . $dbinfo['data'][$key][$zyv['fname']] . "\" >";
                                    } elseif ($config['sypic'] == 1 || $config['sytxt'] == 1) {
                                        $dbinfo['data'][$key][$zyv['fname']] = "<img src=\"/uplods/sytp/" . $dbinfo['data'][$key][$zyv['fname']] . "\"  width=\"100px\">";
                                    } else {
                                        $dbinfo['data'][$key][$zyv['fname']] = "<img src=\"/uplods/pic/" . $dbinfo['data'][$key][$zyv['fname']] . "\"  width=\"100px\">";
                                    }
                                }
                                if (in_array($otype, $dvalue[2])) {
                                    $dbinfo['data'][$key][$zyv['fname']] = "<a href=\"/uplods/pic/" . $dbinfo['data'][$key][$zyv['fname']] . "\" target='_blank'><img src=\"../img/film_link.png\">下载[Download]</a>";
                                }
                                if (in_array($otype, $dvalue[3])) {
                                    $dbinfo['data'][$key][$zyv['fname']] = "<a href=\"/uplods/pic/" . $dbinfo['data'][$key][$zyv['fname']] . "\" target='_blank'><img src=\"../img/report_word.png\">下载[Download]</a>";
                                }
                                break;
                            }
                        case 'radiogroup': {
                                $tempxx = json_decode($zyv['zyz'], true);
                                foreach ($tempxx as $value) {
                                    if ($value['yv'] == $dbinfo['data'][$key][$zyv['fname']]) {
                                        $dbinfo['data'][$key][$zyv['fname']] = $value['xv'];
                                    }
                                }
                                break;
                            }
                        case 'checkboxgroup': {
                                $tempxx = json_decode($zyv['zyz'], true);
                                $nowv = explode('#_#', $dbinfo['data'][$key][$zyv['fname']]);
                                $dbinfo['data'][$key][$zyv['fname']] = '';
                                foreach ($tempxx as $value) {
                                    if (in_array($value['yv'], $nowv)) {
                                        $dbinfo['data'][$key][$zyv['fname']].=$value['xv'] . "<BR>";
                                    }
                                }
                                break;
                            }
                        case 'combo': {
                                $tempxx = json_decode($zyv['zyz'], true);
                                foreach ($tempxx as $value) {
                                    if ($value['yv'] == $dbinfo['data'][$key][$zyv['fname']]) {
                                        $dbinfo['data'][$key][$zyv['fname']] = $value['xv'];
                                    }
                                }
                                break;
                            }
                        case 'combo1': {
                                $config = json_decode($zyv['cfg'], true);
                                $tq = Dgd(array(
                                    'db' => 'd_sevenel',
                                    'tn' => $config['table'],
                                    'cd' => " " . $config['y'] . " = '" . $dbinfo['data'][$key][$zyv['fname']] . "' and  " . $config['conditon'],
                                    'limit' => 1
                                        ));
                                $dbinfo['data'][$key][$zyv['fname']] = $tq[$config['x']];
                                break;
                            }
                        case 'recommend': {
                                $config = json_decode($zyv['cfg'], true);
                                if ($dbinfo['data'][$key][$zyv['fname']] != 0) {
                                    $dbinfo['data'][$key][$zyv['fname']] = "<a href=\"#\" onclick='gxzd(\"" . $dbinfo['data'][$key]['id'] . "\",\"" . $zyv['fname'] . "\",\"0\")' title=\"推荐中！单击取消推荐\"  >  <img src=\"../img/" . $config['paixu'] . "\"></a>    <a href=\"#\"  title=\"排序[order]\"  onclick='tjpx(\"" . $_POST['tid'] . "@" . $_POST['dbname'] . "\",\"" . $zyv['fname'] . "\")' >   <img src=\"../img/sucaiwcom8170000bzc.gif\" ait=\"排序[order]\"></a>";
                                } else {
                                    $dbinfo['data'][$key][$zyv['fname']] = "<a href=\"#\" onclick='gxzd(\"" . $dbinfo['data'][$key]['id'] . "\",\"" . $zyv['fname'] . "\",\"1\")'  title=\"未推荐！单击推荐\"  ><img src=\"../img/flag.png\"></a> <a href=\"#\" title=\"排序[order]\"   onclick='tjpx(\"" . $_POST['tid'] . "@" . $_POST['dbname'] . "\",\"" . $zyv['fname'] . "\")' >  <img src=\"../img/sucaiwcom8170000bzc.gif\" ait=\"排序[order]\"></a>";
                                }
                                break;
                            }
                    }
                }
                $dbinfo['data'][$key]['addtime'] = date("Y-m-d H:i:s");
                $dbinfo['data'][$key]['truetime'] = date("Y-m-d H:i:s", $dbinfo['data'][$key]['at']);
                $dbinfo['data'][$key]['del'] = $dbinfo['data'][$key]['del'];
                $dbinfo['data'][$key]['log'] = $dbinfo['data'][$key]['log'];
                //$dbinfo['data'][$key]['opration'] = $relation->show(array(9, 10), $_POST['tid'], $dbinfo['data'][$key]['id']);
            }
            /* 		
              $tempz=$d_sevenel->Dqsql("select sum(ct) as total from  `se_user` where tid = '".$_POST['tid']."'  and del != '1' ");
              $dbinfo['dq']=$tempb;
              $dbinfo['zong']=$tempz[0]['total'];
             */ echo json_encode($dbinfo);
            break;
        }
    case 'width_change': {
            $id = $_POST['id'];
            Du('sevenel', 'fld', array('wd' => $_POST['width']), 'id', $id, 1);
            echo 'ok';
            break;
        }
    case 'del': {
            $_POST['del'] = 1;
            $_POST['ids'] = json_decode(stripslashes($_POST['ids']));
            if (is_array($_POST['ids'])) {
                foreach ($_POST['ids'] as $id) {
                    Du('sevenel', $_POST['dbname'], $_POST, 'id', $id, 0);
                    $str = $_SESSION['userinfo']['user'] . "_" . (date("Y-m-d H:i:s")) . "_D<br>";
                    $sql = "update se_" . $_POST['dbname'] . " set log =CONCAT('" . $str . "',log) where id=" . $id . "";
                    $d_sevenel->Desql($sql);
                }
            } else {
                Du('sevenel', $_POST['dbname'], $_POST, 'id', $id, 0);
                $str = $_SESSION['userinfo']['user'] . "_" . (date("Y-m-d H:i:s")) . "_D<br>";
                $sql = "update se_" . $_POST['dbname'] . " set log =CONCAT('" . $str . "',log) where id=" . $id . "";
                $d_sevenel->Desql($sql);
            }

            echo '{success:true,msg:\'ok\'}';
            break;
        }

    case 'add': {
            $tree_id = $_GET['tid'];
            Tr($_GET['tid'], 'tid');
            Tr($_GET['bdtid'], 'bdtid');
            Tr($_GET['bdid'], 'bdid');

            $tree = Dgd(array(
                'db' => 'd_sevenel',
                'cd' => "id = $tree_id",
                'tn' => "tree",
                'limit' => 1
                    ));
            $tname = gettabname($tree['table'], $dbcfg['prefix'], true);
            Tr($tname, 'tname');
            if ($_GET['id']) {
                Tr($_GET['id'], 'id');
                $fdada = Dgd(array(
                    'db' => 'd_sevenel',
                    'cd' => " id = '" . $_GET['id'] . "' and del != '1' ",
                    'tn' => "$tname",
                    'limit' => 1
                        ));
                Tr($fdada['gid'], 'gid');
                Tr(preg_replace("/[\s]{2,}/", "", $fdada['lg']), 'lg');
            }
            if ($_GET['id'] == 0) {
                Tr('添加', 'action');
            } else {
                Tr('编辑', 'action');
            }
            if ($showcf) {
                $fcf = '';
                foreach ($showcf as $value) {
                    if ($value['column']) {
                        $fcf.="{
								layout: 'column',
								border: false,
								defaults: {
									columnWidth: '." . floor((10 / $value['column'])) . "',
									border: false
								},items:[
								";
                        for ($i = 0; $i < $value['column']; $i++) {
                            $fcf.="{
									bodyStyle: 'padding-right:10px;',
									items:{
										xtype:'fieldset',
										//draggable:true,
										 frame: false,
										//checkboxToggle : true, 
										bodyStyle:'background:white;',
										title: '<font color=red size=4>" . $value[$i]['title'] . "</font>',
										autoHeight: true,
										items: [";
                            foreach ($value[$i]['zd'] as $zdm) {
                                $fcf.=EXT::GB($zdm) . ",";
                            }
                            $fcf = substr($fcf, 0, -1);
                            $fcf.="]}},";
                        }
                        $fcf = substr($fcf, 0, -1);
                        $fcf.="]},";
                    } else {
                        $fcf.="{
								xtype:'fieldset',
								bodyStyle:'background:white;',
								title: '<font color=red size=4>" . $value['title'] . "</font>',
								autoHeight: true,
								
								items: [";
                        foreach ($value['zd'] as $zdm) {
                            $fcf.=EXT::GB($zdm) . ",";
                        }
                        $fcf = substr($fcf, 0, -1);
                        $fcf.="]},";
                    }
                }
                $fcf = substr($fcf, 0, -1);
                Tr($fcf, 'fcf');
                Tr($plugurl, 'plugurl');
                Tr($plugjs, 'plugjs');
                Tr($fckplugin, 'fckplugin');
            }
            Ts($tmpml . 'add.html');
            break;
        }
    case 'save': {

            $id = $_POST['id'];
            $tree_id = $_POST['tid'];
            $tree = Dgd(array(
                'db' => 'd_sevenel',
                'cd' => "id = $tree_id",
                'tn' => "tree",
                'limit' => '1'
                    ));
            $tabname = gettabname($tree['table'], '', true);
            $fld = Dgd(array(
                'db' => 'd_sevenel',
                'cd' => "tid = $tree_id",
                'tn' => "fld"
                    ));
            /* 		if(!$id){
              $wyyz='user';
              $wztemp=Dgd(array(
              'db'=>'d_sevenel',
              'cd'=>"$wyyz like '".$_POST[$wyyz]."'",
              'tn'=>$tabname,
              'limit'=>'1'
              ));
              if($wztemp!=''){
              ext_request_failure('用户名已存在');
              exit();
              }
              }
             */ foreach ($fld as $key => $value) {
                switch ($value['type']) {
                    case 'datefield': {
                            if ($value['zy'] != 1) {
                                if (strtotime($_POST[$value['fname']])) {
                                    $save[$value['fname']] = strtotime($_POST[$value['fname']]);
                                } else {
                                    $save[$value['fname']] = $_POST[$value['fname']];
                                }
                            } else {
                                $save[$value['fname']] = $_POST[$value['fname']];
                            }
                            break;
                        }
                    case 'checkboxgroup': {
                            $save[$value['fname']] = implode("#_#", $_POST[$value['fname']]);
                            break;
                        }
                    case 'password';
                        {
                            if ($value['yxwk'] == '1') {
                                if ($_POST[$value['fname']] == $_POST[$value['fname'] . '-cfrm']) {
                                    $save [$value['fname']] = md5($_POST[$value['fname']]);
                                } else {
                                    ext_request_failure('两次输入不相同');
                                    exit();
                                }
                            } else {
                                $save [$value['fname']] = md5($_POST[$value['fname']]);
                            }
                            break;
                        }
                    case 'fileup': {
                            //print_r($_FILES);exit;
                            if ($_FILES[$value['fname']]['name'] != '') {
                                $cp = 1;
                                //复制文件
                                $config = json_decode($value['cfg'], true);


                                $dvalue = array(0 => array('rar', 'zip', 'tar', '.tz'),
                                    1 => array('jpg', 'gif', 'png', 'bmp'),
                                    2 => array('mp3', 'mp4', 'avi', 'wmv', 'mid', '.rm', 'mvb', 'mov', 'wma', 'wav'),
                                    3 => array('doc', 'xls', 'txt', 'ocx', 'lsx', 'ppt', 'pdf', 'chm'),
                                    4 => array('doc', 'xls', 'txt', 'ocx', 'lsx', 'ppt', 'pdf', 'chm', 'mp3', 'mp4', 'avi', 'wmv', 'mid', '.rm', 'mvb', 'mov', 'wma', 'wav', 'jpg', 'gif', 'png', 'bmp', 'rar', 'zip', 'tar', '.tz')
                                );
                                if (!$_FILES[$value['fname']]['name']) {
                                    $cp = 0;
                                }
                                $otype = substr(strtolower($_FILES[$value['fname']]['name']), -3);
                                if (!in_array($otype, $dvalue[$config['type']])) {
                                    $cp = 0;
                                    header("Content-type: text/html; charset: UTF-8");
                                    echo "{success:true,msg:'%u4E0A%u4F20%u683C%u5F0F%u4E0D%u5141%u8BB8%21%u8BF7%u8054%u7CFB%u7BA1%u5458%21<BR> Upload format is not allowed! Please contact the administrator!'}";
                                    exit;
                                }
                                if ($_FILES[$value['fname']]['size'] / 1000 > $config['size']) {
                                    $cp = 0;
                                    header("Content-type: text/html; charset: UTF-8");
                                    echo "{success:true,msg:'%u6587%u4EF6%u5927%u5C0F%u8D85%u8FC7%u9650%u5236%21<br> The file size limit expired!'}";
                                    exit;
                                }
                                if ($cp) {
                                    $bsname = time();
                                    $bcname = $bsname . "." . $otype;
                                    $filename = "../../uplods/pic/" . $bcname;
                                    $copymes = copy($_FILES[$value['fname']]['tmp_name'], $filename);
                                    $save[$value['fname']] = $bcname;
                                }
                                if (in_array($otype, $dvalue[1])) {
                                    if ($config['sl1'] == 1) {
                                        @createthumb($_FILES[$value['fname']]['tmp_name'], "." . $otype, $bsname, $config['sl1x'], $config['sl1y'], '1');
                                    }
                                    if ($config['sl2'] == 1) {
                                        @createthumb($_FILES[$value['fname']]['tmp_name'], "." . $otype, $bsname, $config['sl2x'], $config['sl2y'], '2');
                                    }
                                    if ($config['sypic'] == 1) {
                                        $sypicname = "../../uplods/sypic/" . $bcname;
                                        $sypicwz = "../../uplods/" . $config['sytp'] . "";
                                        //echo $sypicwz ,$config['sytp'],$config['sywz'];
                                        @imageWaterMark($filename, $sypicname, $config['sypicwz'], $sypicwz, "", 20, 'wqy-microhei-lite.ttc', "#00FF00");
                                    }
                                    if ($config['sytxt'] == 1) {
                                        $sypicname = "../../uplods/sytxt/" . $bcname;
                                        $sypicwz = "";
                                        @imageWaterMark($filename, $sypicname, $config['sytxtwz'], "", $config['sywz'], $config['sywzdx'], $config['syzt'], "#" . $config['syys']);
                                    }
                                    if ($config['sytxt'] == 1 && $config['sypic'] == 1) {
                                        $filename = "../../uplods/sypic/" . $bcname;
                                        $sypicname = "../../uplods/sytp/" . $bcname;
                                        $sypicwz = "";
                                        @imageWaterMark($filename, $sypicname, $config['sytxtwz'], "", $config['sywz'], $config['sywzdx'], $config['syzt'], "#" . $config['syys']);
                                    }
                                }
                            }
                            break;
                        }
                    default: {
                            $save[$value['fname']] = $_POST[$value['fname']];
                        }
                }
            }
            $save['tid'] = $tree_id;
            !$_POST['lg'] && $save['lg'] = 'zh';
            $_POST['bdid'] && $save['bdid'] = $_POST['bdid'];
            $_POST['bdtid'] && $save['bdtid'] = $_POST['bdtid'];
            !$_POST['gid'] && $save['gid'] = Mct();
            $save['at'] = time();

            //唯一性
            if ($id != 0) {
                if ($listcf['editdisble'] != '') {
                    foreach ($listcf['editdisble'] as $tv) {
                        unset($save[$tv]);
                    }
                }
                if (Du('sevenel', $tabname, $save, 'id', $id, 1)) {
                    ext_request('ok');
                    $str = $_SESSION['userinfo']['user'] . "_" . (date("Y-m-d H:i:s")) . "_U<br>";
                    $sql = "update se_" . $tabname . " set log =CONCAT('" . $str . "',log) where id=" . $id . "";
                    $d_sevenel->Desql($sql);
                }
            } else {
                $save['addtime'] = strtotime(date("Y-m-d H:i:s"));
                $save['log'] = $_SESSION['userinfo']['user'] . "_" . (date("Y-m-d H:i:s")) . "_I<br>";
                if (Di('sevenel', $tabname, $save))
                    ;
                ext_request('ok');
            }
            break;
        }
    case 'yuding': {
            $id = $_POST['id'];
            $prodinfo = Dgd(array(
                'db' => 'd_sevenel',
                'cd' => "id = $id",
                'tn' => "info",
                'limit' => '1'
                    ));
            if ($prodinfo) {
                $insert['tid'] = '108';
                $insert['tt'] = $prodinfo['tt'];
                $insert['pic1'] = $prodinfo['pic1'];
                $insert['ct'] = $prodinfo['ct'];
                $insert['input2'] = $prodinfo['input2'];
                $insert['input1'] = $prodinfo['input1'];
                $insert['ubb1'] = $prodinfo['ubb1'];
                $insert['input4'] = $_SESSION['userinfo']['user'];
                $insert['input5'] = $_POST['num'];
                $insert['input6'] = $_POST['num'] * $prodinfo['ct'];
                $insert['tj1'] = 2;
                $insert['lg'] = 'zh';
                $insert['bdid'] = $prodinfo['id'];
                $insert['bdtid'] = $prodinfo['tid'];
                $insert['gid'] = Mct();
                $insert['at'] = time();
                Di('sevenel', 'info', $insert);
                echo "下单成功，等待卖家确认！";
                exit;
            } else {
                echo "产品出错,请仔细检查！";
                exit;
            }

            break;
        }
    case 'qkzd': {
            $save[$_POST['zd']] = '';
            if (Du('sevenel', $_POST['tname'], $save, 'id', $_POST['id'], 1))
                ext_request('ok'); break;
        }
    case 'gxzd': {
            $save[$_POST['zd']] = $_POST['xz'];
            if (Du('sevenel', $_POST['tname'], $save, 'id', $_POST['id'], 1))
                ext_request('ok'); break;
        }
    default: {
            Ts($tmpml . 'index.html');
            break;
        }
}
?>
